#include<stdlib.h>
#include<vector>
#include<unordered_map>
#include<cstdio>
#include<iostream>
#include<string.h>
using namespace std;

bool Reverse(const char* str,char* dest)
{
  if(str == dest) return false;
  int len = strlen(str);
  int index = 0;
  for(int i = len-1;i>=0;i--) //如果是i = len,然后i>=0，会导致将\0放在dest的0位置，导致什么都不打印
  {
    dest[index++] = str[i];
  }
  dest[len] = '\0';
  //dest[len] = '\0';
  return true;
}
#define PRINT(v) do {\
  for(auto& x:v)   \
    cout << x.first <<" " <<x.second <<endl; \
  }while(0);  

void test()
{
  vector<pair<int,int>> vv{
    {2,1000},
    {3,2000},
    {4,1000},
    {4,1000},
    {5,1001},
  };
  auto it = vv.begin();
  while(it!=vv.end())
  {
    if(it->second == 1000)
      it = vv.erase(it);
    else 
      it++;
  }
  PRINT(vv);
}


void Transition(unsigned char* date,int n) //数组,元素个数
{
  for(int i = 0;i<n;i++)
  {
    //提取当前元素的低4位 高4位
    unsigned char low_bit = date[i]  & 0x0f;
    unsigned char high_bit = (date[i] >> 4) &0x0f ;//high_bit已经到达了低四位
    //比特位交换
    date[i] = (low_bit<<4) | high_bit;
  }
}

void  Print(unsigned char* date,int n)
{
  for(int i = 0;i<n;i++)
    printf("0x%0x    ",date[i]);
  cout << endl;
}
int main()
{
  unsigned char date[5] = {0x98,0x68,0x52,0x37,0x00};
  int sz = sizeof(date) / sizeof(date[0]);
  Print(date,sz);
  Transition(date,sz); 
  Print(date,sz);
  return 0;
}
//int main()
//{
//  //const char* str = "Mango"; 
//  //char dest[40] = {0};
//  //Reverse(str,dest);
//  //printf("%s\n",dest);
//  test();
//  return 0;
//}
